package com.wenyu.wenyuyuedu.adapter.circleAdapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wenyu.wenyuyuedu.R;
import com.wenyu.wenyuyuedu.bean.circle.SearchBean;

import java.util.ArrayList;
import java.util.List;

import static com.wenyu.wenyuyuedu.R.layout.history;

/**
 * Created by Administrator on 2017/3/8.
 * 显示历史搜索
 */

public class SearchAdapter extends BaseAdapter {
    private List<SearchBean.InfoBean.HistoryBean> mHistory = new ArrayList<>();
    private Context context;
    private View view;

    public SearchAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return mHistory.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        MySearchHolder holder = null;
        if (view == null) {
            holder = new MySearchHolder();
            view = View.inflate(context,R.layout.history, null);
            holder.tv_content_name = (TextView) view.findViewById(R.id.tv_content_name);
            view.setTag(holder);
        }
        holder = (MySearchHolder) view.getTag();
        holder.tv_content_name.setText(mHistory.get(i).getSearch_key());
        return view;
    }

    class MySearchHolder {
        TextView tv_content_name;
    }

    public void addAll(List<SearchBean.InfoBean.HistoryBean> history) {
        if(history != null){
            this.mHistory = history;
            notifyDataSetChanged();
        }
    }
}
